#define STB_IMAGE_IMPLEMENTATION //添加这个宏定义，让其只包含相关函数定义的源码
#include "stb/stb_image.h" //用于图像加载
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include <stb/stb_image_resize.h>//用于图像将采样


int main(int argc, char *argv[])
{
    int req_width = 32;
    int req_height = 32;
    int req_channel = 1;

    int img_width = 320;
    int img_height = 240;
    int channel = 1;

    unsigned char *image_data = NULL;
    FILE* file_ = fopen("/data/test1.YUV", "rb+");
    fread(image_data,(img_width*img_height), 1, file_);
    fclose(file_);

    unsigned char *image_resized = (unsigned char *)STBI_MALLOC(req_width * req_height * req_channel);


    int res = stbir_resize_uint8(image_data, img_width, img_height, 0, image_resized, req_width, req_height, 0, channel);
    // printf("==resize is %d==\n", res);

    // char* outputPath = "data/11out.jpg";
    // stbi_write_png(outputPath, req_width, req_height, 1, image_resized, 0);

    // stbi_image_free(image_data);
	// stbi_image_free(image_resized);

    // printf("===save resize==\n");
    // FILE* file_save = fopen("/data/test_resize.YUV", "wb");
    // fwrite(image_resized, 1, (req_width*req_height*req_channel), file_save);
    // fclose(file_save);
    // printf("===save end==\n");
    return 0;
}